Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swc-node/core

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swc-node/core

Faster swc nodejs binding

  • 0.7.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
818K
decreased by-49.27%
Maintainers
1
Weekly downloads
 
Created

What is @swc-node/core?

@swc-node/core is a Node.js binding for the SWC (Speedy Web Compiler) project, which is a super-fast TypeScript/JavaScript compiler written in Rust. It allows you to transform and compile TypeScript and JavaScript code with high performance.

What are @swc-node/core's main functionalities?

Transforming Code

This feature allows you to transform TypeScript or JavaScript code into JavaScript. The `transformSync` function takes the source code and an options object, and returns the transformed code.

const { transformSync } = require('@swc-node/core');

const output = transformSync('const x: number = 1;', { jsc: { parser: { syntax: 'typescript' } } });
console.log(output.code);

Compiling Code

This feature allows you to compile TypeScript or JavaScript code asynchronously. The `compile` function takes the source code and an options object, and returns a promise that resolves to the compiled code.

const { compile } = require('@swc-node/core');

compile('const x: number = 1;', { jsc: { parser: { syntax: 'typescript' } } }).then(output => {
  console.log(output.code);
});

Using with Node.js

This feature allows you to use SWC with Node.js directly. By requiring `@swc-node/register`, you can run TypeScript code in Node.js without pre-compiling it.

require('@swc-node/register');

const x: number = 1;
console.log(x);

Other packages similar to @swc-node/core

Keywords

FAQs

Package last updated on 16 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc